package org.mtdownload.dialogs.checklist;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.DefaultTableModel;

public class CheckListTableModel extends DefaultTableModel {
	private static final long serialVersionUID = 3257844364058112307L;

	public CheckListTableModel(List<String> data) {
		super(new String[]{"Get", "URL"},0);
		init(data);
	}
	
	private void init(List<String> data) {
		for(int i=0;i<data.size();i++){
			addRow(new Object[]{new Boolean(true),data.get(i)});
		}
	}
	
    public Class<?> getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
	
	public List<String> getSelectedValues(){
		List<String> l=new ArrayList<String>();
		for(int i=0;i<getRowCount();i++){
			Boolean b=(Boolean)getValueAt(i,0);
			if(b.booleanValue()){
				l.add((String)getValueAt(i,1));
			}
		}
		return l;
	}
}
